package hamming

import (
	"fmt"
)

const testVersion = 6

type HammingError struct {
	What string
}

func (e HammingError) Error() string {
	return fmt.Sprintf("%v", e.What)
}

func Distance(a, b string) (int, error) {
	if len(a) != len(b) {
		return -1, HammingError{
			fmt.Sprintf("len(%v) != len(%v)", a, b),
		}
	}

	distance := 0
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			distance += 1
		}
	}

	return distance, nil
}
